package kr.ac.kaist.vrowser.fragments;

import kr.ac.kaist.vrowser.R;
import kr.ac.kaist.vrowser.application.VrowserApplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;

public class VrowserBaseFragment extends Fragment {

	protected VrowserApplication app;
	public int buttons[] = new int[6];
	
	public VrowserBaseFragment(){
		super();
		buttons[0] = R.id.button1;
		buttons[1] = R.id.button2;
		buttons[2] = R.id.button3;
		buttons[3] = R.id.button4;
		buttons[4] = R.id.button5;
		buttons[5] = R.id.button6;
	}
	
	public String cutWords(String word, boolean longer) {
		if (longer) {
			if (word.getBytes().length <= 10) {
				return word;
			} else {
				if ((word.substring(0, Math.min(8, word.length())) + "..").getBytes().length <= 10) {
					return (word.substring(0, Math.min(8, word.length())) + "..");
				} else {
					return (word.substring(0, Math.min(6, word.length())) + "..");
				}
			}
		} else {
			if (word.getBytes().length <= 6) {
				return word;
			} else {
				if ((word.substring(0, Math.min(5, word.length())) + "..").getBytes().length <= 7) {
					return (word.substring(0, Math.min(5, word.length())) + "..");
				} else {
					return (word.substring(0, Math.min(3, word.length())) + "..");
				}
			}
		}
	}
		
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		app = (VrowserApplication) getActivity().getApplicationContext();
	}
}
